<?php
    use User\Model\MeetingModel;
?>
<div class="row">
    <div class="col-lg-12">
        <section class="panel">
            <header class="panel-heading">
                学校详情
            </header>
            <div class="panel-body">
                <form class="form-horizontal" method="post"
                      action="/User/Tool/schoolUpdate">
                    <input type="hidden" value="<?php $val = (!empty($school)) ?
                            $school['s_id'] : ''; echo $val;?>" name="schId" id="schId">
                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label need">学校名称:</label>

                        <div class="col-lg-4">
                            <input type="text" class="form-control" name="name" value="<?php $val=(!empty($school)) ?
                            $school['name'] : ''; echo $val;?>" id="name">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label need">学校代码:</label>

                        <div class="col-lg-4">
                            <input type="text" class="form-control" name="code" value="<?php $val=(!empty($school)) ?
                            $school['code'] : ''; echo $val;?>" id="code">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label need">报名时间:</label>

                        <div class="col-lg-4">
                            <input type="text" class="form-control" name="reg_date_s" value="<?php $val=(!empty($school)) ?
                            $school['reg_date_s'] : ''; echo $val;?>" id="reg_date_s">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label need">测试时间:</label>

                        <div class="col-lg-4">
                            <input type="text" class="form-control" name="test_date_s" value="<?php $val=(!empty($school)) ?
                            $school['test_date_s'] : ''; echo $val;?>" id="test_date_s">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 col-sm-2 control-label need">奖项要求:</label>

                        <div class="col-lg-4">
                            <textarea class="form-control" name="award" id="award"><?php $val=(!empty($school)) ?
                            $school['award'] : ''; echo $val;?></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-10">
                            <button class="btn btn-primary" type="submit" id="submit">提交</button>
                            <button class="btn btn-default" type="button" onclick="history.back(-1);">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </section>
    </div>
</div>
<script>

    $("#submit").click(function () {

        var data = $("form").serialize();
        var url = $("form").attr("action");
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            async:false,
            success: function (res) {
                if (res.code == 1) {
                    alert("提交成功");
                    window.location = '/User/Tool/school';
                } else {
                    alert(res.msg);
                }
            }
        });
        return false;
    });
</script>